package com.think.excel;

import org.springframework.boot.context.config.ConfigDataResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

public class ExcelConfigDataResource extends ConfigDataResource {
    private final Resource resource;

    public ExcelConfigDataResource(Resource resource) {
        this.resource = resource;
    }

    public boolean exists() {
        return resource.exists();
    }

    public InputStream getInputStream() throws IOException {
        return resource.getInputStream();
    }

    public String getLocation() {
        try {
            return resource.getURI().toString();
        } catch (IOException e) {
            return resource.getDescription();
        }
    }
}
